<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
   	<%
		if(session.getAttribute("isAdminLogined")==null){
			return;
		}else{
			String isAddminLogined = session.getAttribute("isAdminLogined").toString();
			if(!("true".equals(isAddminLogined))){
				response.sendRedirect("login.jsp");
				return;
			}
		}
		
	%>
   <%
response.addHeader("Cache-Control", "no-cache");
response.addHeader("Expires", "Thu, 01 Jan 1970 00:00:01 GMT");

		List<GuangGao> li = null;
		if(request.getAttribute("guangGaoList")!=null){
			
			li = (List<GuangGao>)request.getAttribute("guangGaoList");
		}

%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<%@page import="java.util.List"%>
<%@page import="com.doone.telmarket.domain.GuangGao"%><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>main</title>
<link rel="stylesheet" rev="stylesheet" href="${pageContext.request.contextPath}/css/admin/style-admin.css" type="text/css" media="all" />
<script src="${pageContext.request.contextPath}/js/jquery.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/js/jquery.ui.draggable.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/js/jquery.alerts.js" type="text/javascript"></script>
<link href="${pageContext.request.contextPath}/css/jquery.alerts.css" rel="stylesheet" type="text/css" media="screen" />


<link rel="stylesheet" type="text/css" media="all" href="${pageContext.request.contextPath}/js/calendar-brown.css"/>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/calendar.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/calendar-zh.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/calendar-action.js"></script>
<script src="${pageContext.request.contextPath}/js/ajaxfileupload.js"
	type="text/javascript"></script>

<script type="text/javascript">
$(document).ready(function(){

			$("#form2").submit(function(){
					if($("#url").val()==""){
						jAlert("请输入广告一链接","消息");
						return false;
	 				}
		});
});


/***********************************************************************************/	
function showProductEditor(){
	document.getElementById("img2").style.display = "";
}

function cancel(){
	document.getElementById("img2").style.display = "none";
}

function uploadImage2(){


	
	var url = document.getElementById("contextPath").value+'/admin/updateGuangGaoImage2';
	if($("#smallImage2").val()==""){
		jAlert("请选择图片",'消息');
		return ;
	}
$.ajaxFileUpload
(   
    {   
        url:url,    
        secureuri:false,   
        fileElementId:'smallImage2',   
        dataType: '',   
        success: function(data, status)   
        {      
           jAlert(status,'消息');
           
           displayDiv();
           if(status=="success"){
        	   location.reload();
           }
        },   
        error: function (data, status, e)   
        {   
        	jAlert("保存文件失败",'消息');
        	displayDiv();
        }   
    }   
);  
}


function mod(id1,url1,path1){
	var modify = document.getElementById("modify");
	var id = document.getElementById("id");
	var url = document.getElementById("url");
	var img  =  document.getElementById("img");
	id.value = id1;
	url.value = url1;
	
	img.src = document.getElementById("contextPath").value+"/"+path1;
	modify.style.display = "";
}



</script>


<style type="text/css">
<!--
.atten {font-size:12px;font-weight:normal;color:#F00;}
-->
</style>
</head>

<body class="ContentBody">

<div style="z-index: 1;height: 1000">
<input id="contextPath" type="hidden" value="${pageContext.request.contextPath}" />
 
<div class="MainDiv">
<table width="99%" border="0" cellpadding="0" cellspacing="0" class="CContent">
  <tr> 
      <th class="tablestyle_title" >主页右下广告图配置</th>
  </tr>
  <tr>
    <td class="CPanel">
		<table border="0" cellpadding="0" cellspacing="0" style="width:100%">
		<tr><td align="left">
		<a href="${pageContext.request.contextPath}/admin/uploadIndexImage.jsp">新增广告</a>
			<a href="${pageContext.request.contextPath}/admin/queryAllGuangGao2">编辑广告</a>
		</td></tr>

		
		
		<tr align="center">
          <td class="TablePanel"></td>
		  </tr>
		  　<tr>
			<TD width="100%">
			 <form action="${pageContext.request.contextPath}/admin/insertGuangGao" enctype="multipart/form-data" method="post" name="fom" id="fom" >
				<fieldset style="height:100%;">
				<legend>编辑广告</legend>
					  <table border="0" cellpadding="2" cellspacing="1" style="width:100%">
					 

					    <tr>
					   <td>序号</td>
					    <td>链接</td>

					      <td>操作</td>
					      <td>操作</td>
					    </tr>
					    <%
					    
					    if(li!=null){
					    	for(int i=0;i<li.size();i++){
					    		%>
					    		 <tr>
					    <td><%=li.get(i).getId() %></td>
					     <td><%=li.get(i).getUrl() %></td>
					      <td><a href="${pageContext.request.contextPath}/admin/deleteGuangGao?id=<%=li.get(i).getId() %>">删除</a></td>
					       <td><a onclick="mod('<%=li.get(i).getId() %>','<%=li.get(i).getUrl() %>','<%=li.get(i).getImgPath() %>');" style="cursor: hand">编辑</a></td>
					    </tr>
					    		<%
					    	}
					    }
					    %>
					  </table>
			 <br />
				</fieldset>	
				</form>
				
								<fieldset style="height:100%;display: none" id="modify" >
				<legend>编辑精彩促销</legend>
				<form action="${pageContext.request.contextPath}/admin/updateGuangGao" id="form2" method="post" enctype="multipart/form-data">
					  <table border="0" cellpadding="2" cellspacing="1" style="width:100%">
					 

					    <tr>
					   <td><input type="hidden" id="id" name="id"  />
					    链接:<input type="text" id="url" name="url"  /><br/>

					      图片：<img title="点击更改图片" id="img" style="cursor: hand" width="180" height="115" onclick="showProductEditor();"/><br/>
					    <div style="display: none" id="img2">选择图片：<input id="upload" type="file" name="uploadFile" />
					    	<input type="button" class="button" value="取消" onclick="cancel();" />
					    </div>  
					      </td>
					    </tr>
					  </table>
					  <input type="submit" value="提交" class="button" /> 
					  </form>
			 <br />
				</fieldset>				
			</TD>
		</TR>
		
		</TABLE>
	
	
	 </td>
  </tr>
		
		</TABLE>
</div>

</div>


</body>
</html>